package com.carleasoft.mps.core.user;

/**
 * @program:
 * @description:
 * @author: ztm
 * @create: 2019/11/22 21:37
 **/
public class ThreadUserContext implements AutoCloseable{

    static final ThreadLocal<UserCacheData> current = new ThreadLocal<>();

    public ThreadUserContext(UserCacheData user) {
        current.set(user);
    }

    public static UserCacheData getCurrentCacheUser() {
        return current.get();
    }

    @Override
    public void close() {
        current.remove();
    }

    public static void set(UserCacheData user){
        current.set(user);
    }

}
